package com.wang.mandkey.activity;

import java.io.IOException;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.wang.mandkey.R;
import com.wang.mandkey.tool.Tool;
import com.wang.mandkey.utils.ProjectEnvironment;
import com.wang.mandkey.utils.SharePersistent;

public class GetPcActivity extends BaseActivity {

	private Button mTextViewYes;
	private Button mTextViewNo;
	private Button mTextViewNolonger;
	private Button mTextViewHelp;
	private LinearLayout mLinearlayout;

	private String tag = "GetPcActivity";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setUpView();
	}

	@Override
	void setUpView() {

		setContentView(R.layout.notify_get_pc);
		mLinearlayout = (LinearLayout) findViewById(R.id.linearLayoutContent);
		mTextViewYes = (Button) findViewById(R.id.textViewYes);
		mTextViewNo = (Button) findViewById(R.id.textViewNo);
		mTextViewNolonger = (Button) findViewById(R.id.textViewNoLonger);
		mTextViewHelp = (Button) findViewById(R.id.textViewHelp);

		mTextViewYes.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Tool.startOtherActivity(GetPcActivity.this,
						SettingActivity.class);
				SharePersistent.savePerference(GetPcActivity.this,
						ProjectEnvironment.STRING_KEY_NOTIFY, "1");
				finish();
			}
		});

		mTextViewNo.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				try {
					Tool.mkdir("/sdcard/无线鼠盘");
					Tool.copyAssetFile2Sdcard(GetPcActivity.this, "pc.zip",
							"/sdcard/无线鼠盘/");
					Toast.makeText(GetPcActivity.this,
							"拷贝完成,请把sd卡'无线鼠盘'文件下面内容拷贝到电脑后使用!",
							Toast.LENGTH_LONG).show();
					TextView textView = new TextView(GetPcActivity.this);
					textView.setText("你已经获得pc端，请把sd卡里面的无线鼠盘文件夹下的压缩包拷贝到电脑上使用！");
					mLinearlayout.addView(textView);
				} catch (IOException e) {
					e.printStackTrace();
					Log.e(tag, "e:" + e.toString());
					Toast.makeText(GetPcActivity.this, "拷贝失败，请检查是否插好sdk卡！",
							Toast.LENGTH_SHORT).show();
				}

			}
		});

		mTextViewNolonger.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				SharePersistent.savePerference(GetPcActivity.this,
						ProjectEnvironment.STRING_KEY_NOTIFY, "1");
				finish();
			}
		});
		mTextViewHelp.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Tool.startOtherActivity(GetPcActivity.this, HelpActivity.class);
			}
		});
	}
}
